package lotus.blog.lotusblog.utils;

import lombok.Data;

import java.io.Serializable;

@Data
public class ResultTemplate implements Serializable {
    private String code;
    private String msg;
    private Object data;
    public static ResultTemplate succ(Object data) {

        ResultTemplate m = new ResultTemplate();
        m.setCode("0");
        m.setData(data);
        m.setMsg("操作成功");
        return m;
    }
    public static ResultTemplate succ(String mess, Object data) {
        ResultTemplate m = new ResultTemplate();
        m.setCode("0");
        m.setData(data);
        m.setMsg(mess);
        return m;
    }
    public static ResultTemplate fail(String mess) {
        ResultTemplate m = new ResultTemplate();
        m.setCode("-1");
        m.setData(null);
        m.setMsg(mess);
        return m;
    }
    public static ResultTemplate fail(String mess, Object data) {
        ResultTemplate m = new ResultTemplate();
        m.setCode("-1");
        m.setData(data);
        m.setMsg(mess);
        return m;
    }
    public static ResultTemplate authFail(String mess) {
        ResultTemplate m = new ResultTemplate();
        m.setCode("-2");
        m.setData(null);
        m.setMsg(mess);
        return m;
    }

}

